<?php

require_once '../data/connect.class.php';
require_once '../data/pager.class.php';
$connect = new Connect("localhost","root","","email");
$param = $_POST['param'];
if (isset($param)) {
	if ($param=='list') {
		
		$url = $_SERVER['PHP_SELF'];
		$sql = "select * from admin_unsubscripted";
		$currentId = 1;
		$pageSize = 5;
		
		if (isset($_POST['currentId']) && $_POST['currentId'] > 0) {
			$currentId = $_POST['currentId'];
		}
	    if (isset($_POST['pageSize']) && $_POST['pageSize'] > 0) {
			$_SESSION['pageSize']=$_POST['pageSize'];
		}
		
	    if (isset($_SESSION['pageSize'])) {
			$pageSize = $_SESSION['pageSize'];
		} else {
			$_SESSION['pageSize'] = $pageSize;
		}
		
		$array = array();
		$array['pageSize'] = $pageSize;
		$array['sql']=$sql;
		$array['currentId']=$currentId;
		$array['db']=$connect;
		$pager = new Pager($array);
		
        $pageData = $pager->getPageData();
        $resultSet = $pageData['pageData'];
		
        echo "<div class='page_user_row'>";
		echo "  <div class='page_addr_content'>";
		echo "     <strong>用户名</strong>";
		echo "  </div>";
		echo "  <div class='page_addr_content'>";
		echo "    <strong>邮件地址</strong>";
		echo "  </div>";
		echo "  <div class='page_addr_content'>";
		echo "    <strong>退订原因</strong>";
		echo "  </div>";
		echo "</div>";
		
	    foreach($resultSet as $res) {
			echo "<div class='page_user_row'>";
			echo "  <div class='page_addr_content'>".$res['addr_name']."</div>";
			echo "  <div class='page_addr_content'>".$res['addr']."</div>";
			echo "  <div class='page_addr_content'>".$res['reason']."</div>";
			echo "</div>";
		}
		
		
	    echo "<div style='float:right;'>";
	    if (!$pageData['isFirstPage']) {
			echo "<div style='float:left;cursor:pointer;' onclick='user_manage(\"".$url."\",\"list\",1,\"\")'>首页</div>&nbsp;";
		}
		for ($i=1; $i < $pageData['totalPages']+1; $i++) {
			if ($i == $pageData['currentPage']) {
				echo "<div style='color:red;float:left'>[".$i."]</div>&nbsp;";
			} else {
				echo "<div style='float:left;cursor:pointer;' onclick='user_manage(\"".$url."\",\"list\",[".$i."],\"\")'>[".$i."]</div>&nbsp;";
			}
			
		}
	    if (!$pageData['isLastPage']) {
			echo "<div style='float:left;cursor:pointer;' onclick='user_manage(\"".$url."\",\"list\",".$pageData['totalPages'].",\"\")'>尾页</div>&nbsp;";
		}
		echo "</div>";
	}
}

?>